package main

import (
	"github.com/micro/go-micro"
	"github.com/micro/go-micro/registry"
	"github.com/micro/go-plugins/registry/consul"
	go_micro_user "go_micro_microservices/service/Interface"
	"go_micro_microservices/service/ServerImpl"
	"log"
)

func main() {
	//注册consul
	newRegistry := consul.NewRegistry(
		registry.Addrs("106.12.7.53:8500"),
	)

	newService := micro.NewService(
		micro.Address(":8001"),      //注入端口
		micro.Name("micro_demo"),    //注入名称
		micro.Registry(newRegistry), //注入服务
	)
	newService.Init()
	err := go_micro_user.RegisterUserServiceHandler(newService.Server(), new(ServerImpl.UserServiceImpl))
	if err != nil {
		log.Fatal("服务启动失败")
	}
	newService.Run()
}
